package com.shop.bean;

import java.util.List;

public class Page<T> {
	private List<T> data;//所有信息
	private int pageSize;//页大小
	private int pageNum;//页号
	private int totalNums;//总条数
	private int totalPages;//总页数
	private boolean hasPrev;//是否有上一页
	private boolean hasNext;//是否有下一页
	public List<T> getData() {
		return data;
	}
	public void setData(List<T> data) {
		this.data = data;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getTotalNums() {
		return totalNums;
	}
	public void setTotalNums(int totalNums) {
		this.totalNums = totalNums;
	}
	public int getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
	public boolean isHasPrev() {
		return hasPrev;
	}
	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}
	public boolean isHasNext() {
		return hasNext;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public Page() {
		
	}
	public Page(List<T> data,int pageNum ,int pageSize , int totalNums) {
		super();
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalNums = totalNums;
		this.totalPages = totalNums % pageSize == 0 ? (totalNums/pageSize):((totalNums/pageSize)+1);
		if(pageNum<=1) {
			this.hasPrev=false;
		}else {
			this.hasPrev=true;
		}
		
		if(pageNum>=totalPages) {
			this.hasNext=false;
		}else {
			this.hasNext=true;
		}
	}
		
	
}
